package com.mycompany.myapp.service.impl;

import com.mycompany.myapp.service.PassageService;
import com.mycompany.myapp.domain.Passage;
import com.mycompany.myapp.repository.PassageRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 * Service Implementation for managing Passage.
 */
@Service
@Transactional
public class PassageServiceImpl implements PassageService {

    private final Logger log = LoggerFactory.getLogger(PassageServiceImpl.class);

    private final PassageRepository passageRepository;

    public PassageServiceImpl(PassageRepository passageRepository) {
        this.passageRepository = passageRepository;
    }

    /**
     * Save a passage.
     *
     * @param passage the entity to save
     * @return the persisted entity
     */
    @Override
    public Passage save(Passage passage) {
        log.debug("Request to save Passage : {}", passage);
        return passageRepository.save(passage);
    }

    /**
     * Get all the passages.
     *
     * @param pageable the pagination information
     * @return the list of entities
     */
    @Override
    @Transactional(readOnly = true)
    public Page<Passage> findAll(Pageable pageable) {
        log.debug("Request to get all Passages");
        return passageRepository.findAll(pageable);
    }

    /**
     * Get one passage by id.
     *
     * @param id the id of the entity
     * @return the entity
     */
    @Override
    @Transactional(readOnly = true)
    public Passage findOne(Long id) {
        log.debug("Request to get Passage : {}", id);
        return passageRepository.findOne(id);
    }

    /**
     * Delete the passage by id.
     *
     * @param id the id of the entity
     */
    @Override
    public void delete(Long id) {
        log.debug("Request to delete Passage : {}", id);
        passageRepository.delete(id);
    }
}
